
<template>
  <div class="codeCard">
    <Title>{{ title }}</Title>
    <Descripe>{{ describe }}</Descripe>
    <ShowCodeCard :code="codeBlock">
      <slot></slot>
    </ShowCodeCard>
    <slot name="more"></slot>
    <TableCard title="属性(props)" :data="attrs" :columns="attrColumn"></TableCard>
    <TableCard title="事件(events)" :data="events" :columns="eventColumn"></TableCard>
    <TableCard title="方法(methods)" :data="methods" :columns="methodColumn"></TableCard>
    <TableCard title="插槽(slots)" :data="slots" :columns="slotColumn"></TableCard>
    <slot name="tip"></slot>
  </div>
</template>

<script>
import ShowCodeCard from "./showCodeCard.vue";
import Descripe from "./descripeCard.vue";
import Title from "./titleCard.vue";
import TableCard from "./tableCard.vue";
export default {
  components: { ShowCodeCard, Descripe, Title, TableCard },
  props: {
    title: {
      type: String,
      default: "",
    },
    describe: {
      type: String,
      default: "",
    },
    codeBlock: {
      type: String | Array,
      default() {
        return [];
      },
    },
    attrs: {
      type: Array,
      default() {
        return [];
      },
    },
    events: {
      type: Array,
      default() {
        return [];
      },
    },
    methods: {
      type: Array,
      default() {
        return [];
      },
    },
    slots: {
      type: Array,
      default() {
        return [];
      },
    },
  },
  data() {
    return {
      flag: false, //代码显示开关
      attrColumn: [
        {
          label: "参数",
          prop: "name",
        },
        {
          label: "说明",
          prop: "describe",
        },
        {
          label: "类型",
          prop: "type",
        },
        {
          label: "可选值",
          prop: "emun",
        },
        {
          label: "默认值",
          prop: "default",
        },
      ],
      eventColumn: [
        {
          label: "事件名称",
          prop: "name",
        },
        {
          label: "说明",
          prop: "describe",
        },
        {
          label: "参数",
          prop: "params",
        },
      ],
      methodColumn: [
        {
          label: "方法名称",
          prop: "name",
        },
        {
          label: "说明",
          prop: "describe",
        },
        {
          label: "参数",
          prop: "params",
        },
      ],
      slotColumn: [
        {
          label: "方法名称",
          prop: "name",
        },
        {
          label: "说明",
          prop: "describe",
        },
      ],
    };
  },
};
</script>

<style lang="stylus" scoped>
.codeCard {
}
</style>
